Dynomotion

Group: DynoMotion Message: 78 From: s.astrom Date: 11/4/2009
Subject: C help wanted.
I need some help writing a code that sets a bit to 1 with a push on a button, and the same button should put the bit to 0 if pushed again, if its set to 1.
On/off with the same button in Kmotioncnc.

Or if its possible to set the bit to 1 under a short period of time, like for 1 sec. Then it should go back to 0.

I want to be able to turn my water on and off with the same button.

Hope u guys understand what i'm talking about
Group: DynoMotion Message: 79 From: Tom Kerekes Date: 11/4/2009
Subject: Re: C help wanted.
Try This:
 
#include "KMotionDef.h"
 
#define BITNO 46  // change this to the bit that should toggle
 
main()
{
    SetBitDirection(BITNO,1);  // makes sure the bit is an output
    if (ReadBit(BITNO))
        ClearBit(BITNO);  // if bit is set, clear it
    else
        SetBit(BITNO);
}